<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link type="text/css" href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/loading.css" />
		<link rel="stylesheet" href="../css/my-auditmanage-zx.css" />
		<style type="text/css">
			[v-cloak] {
				display: none !important;
			}
			
			.mui-content-body p {
				font-size: 18px;
				line-height: 26px;
				padding-bottom: 5px;
				/*letter-spacing: 0.3px;*/
				color: #464646;
				font-family: Roboto;
			}
			
			.handle-status {
				color: #fff;
				display: inline;
				position: absolute;
				top: 0;
				right: 0;
			}
		</style>
	</head>

	<body>
		<div id="Loading">
			<div class="loader-inner ball-beat">
				<div></div>
				<div></div>
				<div></div>
			</div>
		</div>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title"></h1>
		</header>
		<!--v-cloak-->
		<div class="mui-content" id="mui-content" v-cloak>
			<div style="padding:0 15px">
				<h4 style="line-height: 24px;">{{items.title}}</h4>
				<div class="article-sub" style="margin-top: 12px; font-size: 14px; color: #b8b8b8;">
					<span>{{items.organizationName}}</span> <br />
					<span>{{items.creationTime}}</span></div>
				<div class="mui-content-body" v-html="items.body">
					<!--<p>
						改革是教育事业发展的根本动力。大力推进教育体制改革创新，才能使我国教育越办越好、越办越强。
					</p>
					<p>
						大力推进教育体制改革创新，就要坚持我国教育现代化的社会主义方向，坚持教育公益性原则，把教育公平作为国家基本教育政策。教育公平是社会公平的重要基础，必须坚持以人民为中心发展教育，努力让每个人享有受教育的机会，获得发展自身、奉献社会、造福人民的能力。要加快建成伴随每个人一生的教育，让学习成为每个人的生活习惯和生活方式，实现人人皆学、处处能学、时时可学；要加快建成平等面向每个人的教育，努力使每个人不分性别、不分城乡、不分地域、不分贫富、不分民族都能接受良好教育；要加快建成适合每个人的教育，努力使不同性格禀赋、不同兴趣特长、不同素质潜力的学生都能接受符合自己成长需要的教育；要加快建成更加开放灵活的教育，努力使教育选择更多样、成长道路更宽广，使学业提升通道、职业晋升通道、社会上升通道更加畅通。
					</p>-->
				</div>
			</div>
			<div style="width:100%;height: 15px; background: #f0f0f0;" v-show="!flaghandle"></div>
			<div style="padding:0 15px" v-show="!flaghandle">
				<div style="padding:10px 10px 0; border-bottom: 1px solid #ccc; margin-bottom: -1px;">
					<div class="mui-input-row mui-navigate-right" @click="handleResult">
						<label style="line-height: 22px; padding: 11px 15px 11px 0; ">审核类型</label>
						<input id="handleResult" type="text" data-options='{}' readonly class="mui-input-clear mui-input" placeholder="请选择审核类型">
					</div>
				</div>
				<div style="padding:10px;" v-show="status == 2">
					<div class="mui-input-row mui-navigate-right" @click="handleDisagree">
						<label style="line-height: 22px; padding: 11px 15px 11px 0;"></label>
						<input id="handleDisagree" type="text" data-options='{}' readonly class="mui-input-clear mui-input" placeholder="请选择不同意类型">
					</div>
				</div>
				<div class="row mui-input-row">
					<textarea class="mui-input-clear question" placeholder="请填写审核意见..." v-model="description"></textarea>
				</div>
				<div style="margin-bottom: 10px; margin-top: -5px;" v-show="flag">
					<button type="button" class="mui-btn mui-btn-primary mui-col-xs-2" style="visibility: hidden;">提交</button>
					<button @click="submitHandle" type="button" class="mui-btn mui-btn-primary mui-col-xs-4">提交</button>
					<button @click="cancelHandle" type="button" class="mui-btn mui-btn-danger mui-col-xs-4">取消</button>
				</div>
			</div>
			<div style="width:100%;height: 15px; background: #f0f0f0;" v-show="flaghandleflow"></div>
			<h6 style="padding-left: 10px;" v-show="flaghandleflow">审核记录</h6>
			<div v-show="flaghandleflow">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell" style="padding: 11px 10px 11px 5px;" v-for="item in handleflow">
						<div class="mui-col-xs-12">
							<img class="mui-media-object mui-pull-left" style="border-radius: 5px;" src="../images/qq.png">
							<div class="mui-media-body mui-col-xs-8">
								<!--<div class="mui-ellipsis-2">{{item.description}}</div>-->
								<div>{{ !item.description ? '暂无审核备注':item.description}}</div>
							</div>
							<p v-if="item.status == 1" class="mui-pull-right mui-badge mui-badge-primary handle-status">发起</p>
							<p v-else-if="item.status == 2" class="mui-pull-right mui-badge mui-badge-success handle-status">已结束</p>
							<p v-else-if="item.status == 3" class="mui-pull-right mui-badge mui-badge-warning handle-status">终止</p>
							<p v-else-if="item.status == 4" class="mui-pull-right mui-badge mui-badge-danger handle-status">取消</p>
							<p v-else class="mui-pull-right mui-badge mui-badge-purple handle-status">被退回</p>

							<div style="margin-left: 55px; padding-right:60px;font-size: 16px;">
								<p style="color: #333; height: 20px; line-height: 20px; background: #f0f0f0;">{{item.user.name}}【处理人】</p>
								<p style="display:inline;">{{item.handleTime}}【处理时间】</p>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</body>

</html>
<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
<script type="text/javascript" src="../js/mui.min.js"></script>
<script type="text/javascript" src="../js/mui.picker.min.js"></script>
<script type="text/javascript" src="../js/mui.zoom.js"></script>
<script type="text/javascript" src="../js/mui.previewimage.js"></script>
<script type="text/javascript" src="../js/config.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/localStorage.js"></script>
<script type="text/javascript" src="../js/vue.min.js"></script>
<script type="text/javascript">
	var detailid, columname, articlevm, workid, nodeid, flaghandle, flaghandleflow;
	mui.init();

	mui.previewImage();
	mui.plusReady(function() {

		flaghandle = plus.webview.currentWebview().type == 0 ? false : true; // false 代表待办，有审核功能操作
		flaghandleflow = false;
		detailid = plus.webview.currentWebview().detailid;
		columname = plus.webview.currentWebview().columname;
		workid = plus.webview.currentWebview().workid;
		nodeid = plus.webview.currentWebview().nodeid;

		initDom();

		initData(detailid);

		//	查看审核流程信息
		if(flaghandle) {
			initHandleData(workid);
		}

	});

	//	初始化DOM
	function initDom() {
		articlevm = new Vue({
			el: "#mui-content",
			data: {
				items: [],
				flag: false, // 是否审核
				disagreenstatus: '',
				description: '', //办理结果描述
				status: '',
				flaghandle: flaghandle, //是否已处理审核
				flaghandleflow: flaghandleflow,
				handleflow: [] // 处理流程
			},
			methods: {

				//	选择处理审核类型
				handleResult: function() {
					var userPicker = new mui.PopPicker();
					userPicker.setData([{
							"value": 1,
							"text": "同意"
						},
						{
							"value": 2,
							"text": "不同意"
						},
						{
							"value": 3,
							"text": "已阅"
						}
					]);

					var userResult = document.getElementById('handleResult');
					userPicker.show(function(items) {
						userResult.value = items[0].text;
						articlevm.status = items[0].value;
						articlevm.flag = true;
						//返回 false 可以阻止选择框的关闭
						//return false;
					});
				},

				//	选择不同意类型
				handleDisagree: function() {
					var userPicker = new mui.PopPicker();
					userPicker.setData([{
							"value": 1,
							"text": "继续"
						},
						{
							"value": 2,
							"text": "终止"
						},
						{
							"value": 3,
							"text": "退回"
						}
					]);

					var userResult = document.getElementById('handleDisagree');
					userPicker.show(function(items) {
						userResult.value = items[0].text;
						articlevm.disagreenstatus = items[0].value;
						//返回 false 可以阻止选择框的关闭
						//return false;
					});
				},

				// 	处理审核
				submitHandle: function() {
					var status = this.status;
					var disagreenstatus = this.status == 2 ? this.disagreenstatus : '';
					var description = this.description;

					if(status == 2 && this.disagreenstatus == '') {
						mui.toast('请选择不同意的处理类型');
						return;
					}

					ctdj.workflow.handle(workid, nodeid, status, disagreenstatus, description, function(r) {
						if(r.success) {
							articlevm.flaghandle = true;
							//	推送到本人最近会话信息
							var msgmyauditPage = plus.webview.getWebviewById('my-auditmanage');
							if(msgmyauditPage) {
								mui.fire(msgmyauditPage, 'msgAuditmanage');
							}
						}
					});
				},

				//	取消审核
				cancelHandle: function() {
					document.getElementById('handleResult').value = '';
					this.status = '';
					this.description = '';
					this.disagreenstatus = '';
					this.flag = false;
				},
			},
		})
	};

	// 初始化详情页数据
	function initData(detailid) {
		ctdj.cms.getArticle(detailid, function(r) {
			if(r.success) {
				r.result.creationTime = r.result.creationTime.split('.')[0].replace('T', ' ');
				//console.log('r.result:' + JSON.stringify(r.result));
				articlevm.items = r.result;
				$(".mui-title").text(r.result.title);
			}

			if($('#Loading').length > 0) {
				setTimeout(function() {
					document.body.removeChild(document.getElementById('Loading'));
				}, 200)
			}

		});
	}

	//	初始化流程审核数据
	function initHandleData(workid) {
		articlevm.flaghandleflow = true;
		//console.log(articlevm.flaghandleflow);
		ctdj.workflow.getHandleRecord(workid, function(r) {
			//console.log('r:' + JSON.stringify(r));
			if(r.success) {
				var handleflowdata = r.result;
				if(handleflowdata.length > 0) {
					$.each(handleflowdata, function(index, item) {
						item.createTime = item.createTime.split('.')[0].replace('T', ' ');
						item.handleTime = item.handleTime.split('.')[0].replace('T', ' ');
					});
					articlevm.handleflow = r.result;
				}
				//console.log(JSON.stringify(articlevm.handleflow));
			}
		})
	}
</script>